<?php


namespace app\api\validate;


use think\Validate;

class UserAddressValidate extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'address_id' => ['require', 'gt:0'],
        'province' => ['require'],
        'city' => ['require'],
        'area' => ['require'],
        'detail' => ['require'],
        'name' => ['require'],
        'mobile' => ['require'],
        'is_default' => ['require', 'in:0,1'],
    ];

    /**
     * 提示消息
     */
    protected $message = [];

    /**
     * 验证场景
     */
    protected $scene = [
        'getAddressDetail' => ['address_id'],
        'addAddress' => ['province','city','area','detail','name','mobile','is_default'],
        'editAddress' => ['address_id','province','city','area','detail','name','mobile','is_default'],
        'addDefault' => ['address_id'],
        'deleteAddress' => ['address_id'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'address_id' => '地址ID',
            'province' => '省',
            'city' => '市',
            'area' => '区',
            'detail' => '详细地址',
            'name' => '收货人',
            'mobile' => '联系电话',
            'is_default' => '是否默认地址设置',
        ];
        parent::__construct($rules, $message, $field);
    }
}